﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.AccessControl;
using System.Security.Principal;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.IO.DirectoryInfo folderInfo = new System.IO.DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Tauschformat\\Data");
            DirectorySecurity folderSecurity = folderInfo.GetAccessControl();

            SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
            FileSystemAccessRule rule = new FileSystemAccessRule(sid, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow);

            folderSecurity.AddAccessRule(rule);
            folderInfo.SetAccessControl(folderSecurity);
        }
    }
}
